<template>
	  <view class="container">
	    <!-- 输入框 -->
	    <input type="text" v-model="newInputValue" placeholder="请输入拆分金额" @input="change">
	    
	    <!-- 删除按钮 -->
	    <img :src=url class="remove" @click="clearInput" v-if="showDelete">
	  </view>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				required: false,
				default: false
			},
			value: ''
		},
		name:"remove",
		data() {
			return {
				newInputValue:"",//存储输入框的值
				showDelete: false,
				url:"../static/del.png",
			};
			
		},
		mounted() {
			this.showDelete = this.show
			this.newInputValue = this.value
		},
		methods: {
			clearInput(){
				this.newInputValue = ''
				this.$emit('remove')
			},
			change(val){
				this.$emit('update:value',this.newInputValue)
			}
		}
	}
</script>

<style scoped>
.container {
	position: relative;
	width: 100%;
	height: 50px;
}
input{
	border: 2px solid #eee;
	padding: 8px;
	font-size: 16px;
	border-radius: 4px;
	width: calc(100%-70px);
}
.remove {
	position: absolute;
	top: 0px;
	right: -12px;
	display: inline-block;
	padding: 4px 12px;
	font-size: 14px;
	color: white;
	cursor: pointer;
	border: none;
	border-radius: 4px;
}
</style>